package com.bianyuanren.quartz.task;

import com.bianyuanren.common.utils.StringUtils;
import com.bianyuanren.v4.service.member.IPpMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * 定时任务调度测试
 * 
 * @author bianyuanren
 */
@Component("ryTask")
public class RyTask {

    @Autowired
    private IPpMemberService ppMemberService;

    @Autowired
    private RedisTemplate redisTemplate;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    /**
     * 会员到期后修改每天滑动次数
     */
   /* public void memberSlide(){
        System.out.println("进入定时任务");
        //调用需要定时清理的数据 获取所有用户的开通会员时间
        SysSet sysSet = JSON.parseObject(redisTemplate.opsForValue().get("sysSet").toString(), SysSet.class);
        Date date=new Date();
        //只查询开通过会员的用户
        List<PpMember> ppMembers = ppMemberService.selectList();
        for (PpMember ppMember : ppMembers) {
            //判断会员是否到期
            if (date.compareTo(ppMember.getVipCloseTime()) > 0){
                //修改滑动次数
                redisTemplate.opsForHash().put("pp:member:slide:" + ppMember.getId(), "totalNum", Long.valueOf(sysSet.getRegisterFreeNum()));
                redisTemplate.opsForHash().put("pp:member:slide:" + ppMember.getId(), "num", 0);
                redisTemplate.opsForHash().put("pp:member:slide:" + ppMember.getId(), "date", DateUtils.getDate());
                System.out.println("执行定时任务");
            }
        }
    }*/
}
